package com.youlai.system.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.youlai.system.model.entity.Approval;
import com.youlai.system.mapper.ApprovalMapper;
import com.youlai.system.model.query.ApprovalQuery;
import com.youlai.system.service.IApprovalService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.Data;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 只茂瑞
 * @since 2024-06-25
 */
@Service
@Data
public class ApprovalServiceImpl extends ServiceImpl<ApprovalMapper, Approval> implements IApprovalService {

    private final ApprovalMapper approvalMapper;


    @Override
    public PageInfo<Approval> getAttendPage(ApprovalQuery approvalQuery) {
        PageHelper.startPage(approvalQuery.getPageNum(), approvalQuery.getPageSize());

        List<Approval> list = this.list();
        System.out.println(list);
        PageInfo<Approval> pageInfo = new PageInfo<>(list);

        return pageInfo;
    }

    @Override
    public Integer updateApprovalStatus(Approval approval) {
        approvalMapper.updateStatus(approval);
        return 0;
    }

    @Override
    public Approval getApprovalForm(Long id) {
        Approval approval = this.getById(id);
        return approval;
    }

    @Override
    public Integer saveApprovalStatus(Approval approval) {
        this.save(approval);
        return approval.getId();
    }

}
